using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;

namespace FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts
{
    [KnownType(typeof(ProductCriteria))]
    [DataContract(Namespace = WebConstants.ServiceNamespace)]
    public class Product : BindingModelBase<Product>
    {
        private int productID;
        [Key]
        [DataMember]
        public int ProductID
        {
            get { return productID; }
            set
            {
                if (!Equals(productID, value))
                {
                    productID = value;
                    RaisePropertyChanged(() => ProductID);
                }
            }
        }

        private string productCode;
        [DataMember]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Mã thành phẩm không được để trống.")]
        [StringLength(10, ErrorMessage = "Mã thành phẩm không dài quá 10 kí tự.")]
        public string ProductCode
        {
            get { return productCode; }
            set
            {
                if (!Equals(productCode, value))
                {
                    productCode = value;
                    RaisePropertyChanged(() => ProductCode);
                }
            }
        }

        public string ProductCodeSearch
        {
            get { return productCode; }
            set
            {
                if (!Equals(productCode, value))
                {
                    productCode = value;
                    RaisePropertyChanged(() => ProductCodeSearch);
                }
            }
        }

        private string productName;
        [DataMember]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Tên thành phẩm không được để trống.")]
        [StringLength(50, ErrorMessage = "Mã thành phẩm không dài quá 50 kí tự.")]
        public string ProductName
        {
            get { return productName; }
            set
            {
                if (!ReferenceEquals(productName, value))
                {
                    productName = value;
                    RaisePropertyChanged(() => ProductName);
                }
            }
        }

        public string ProductNameSearch
        {
            get { return productName; }
            set
            {
                if (!ReferenceEquals(productName, value))
                {
                    productName = value;
                    RaisePropertyChanged(() => ProductNameSearch);
                }
            }
        }

        private string description;
        [DataMember]
        public string Description
        {
            get { return description; }
            set
            {
                if (!ReferenceEquals(description, value))
                {
                    description = value;
                    RaisePropertyChanged(() => Description);
                }
            }
        }

        private long quantity;
        [DataMember]
        public long Quantity
        {
            get { return quantity; }
            set
            {
                if (!Equals(quantity, value))
                {
                    quantity = value;
                    RaisePropertyChanged(() => Quantity);
                }
            }
        }

        private double pricePerUnit;
        [DataMember]
        public double PricePerUnit
        {
            get { return pricePerUnit; }
            set
            {
                if (!Equals(pricePerUnit, value))
                {
                    pricePerUnit = value;
                    RaisePropertyChanged(() => PricePerUnit);
                }
            }
        }

        private bool isDelete;
        [DataMember]
        public bool IsDelete
        {
            get { return isDelete; }
            set
            {
                if (!Equals(isDelete, value))
                {
                    isDelete = value;
                    RaisePropertyChanged(() => IsDelete);
                }
            }
        }

        private ObservableCollection<Material> materialCollection;
        [DataMember]
        public ObservableCollection<Material> MaterialCollection
        {
            get { return materialCollection; }
            set
            {
                if (!ReferenceEquals(materialCollection, value))
                {
                    materialCollection = value;
                    RaisePropertyChanged(() => MaterialCollection);
                }
            }
        }

        private Warehouse warehouse;
        [DataMember]
        public Warehouse Warehouse
        {
            get { return warehouse; }
            set
            {
                if (!ReferenceEquals(warehouse, value))
                {
                    warehouse = value;
                    RaisePropertyChanged(() => Warehouse);
                }
            }
        }
    }
}
